import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;

import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;

public class controller implements Initializable {

    @FXML
    private TextArea allStatus;

    @FXML
    private TextArea pkRecord;

    @FXML
    private Label mount;

    @FXML
    private Label monitorStatus;



    @Override
    public void initialize(URL location, ResourceBundle resources) {

    }

    public void setMount(String str) {
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                mount.setText(str);
            }
        });
    }

    public void setMonitorStatus(String str) {
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                monitorStatus.setText(str);
            }
        });
    }

    public void setPkRecord(List<String> pkRecords) {

        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                for(int i=0;i<pkRecords.size();i++){
                    pkRecord.appendText(pkRecords.get(i)+"\n");
                }
                pkRecord.appendText("===============\n");
            }
        });
    }

    public void setAllStatus(Map<String, String> serverData) {
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                for (Map.Entry<String, String> sd : serverData.entrySet()) {
                    allStatus.appendText(sd.getValue()+"\n");
                }
                allStatus.appendText("=========\n");
            }
        });
    }



}
